<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <template id="temp">
    <div id="coolDiv">
      这是内容
    </div>
  </template>
</body>
<script>
  let temp = document.querySelector("#temp");
  let coolDiv = temp.content.querySelector("#coolDiv");
  coolDiv.textContent = "新的内容";

  document.body.appendChild(coolDiv);
</script>
</html>